<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	font-size: 12px;
}
-->
</style></head>

<body>
<?php
include_once("conn.php");
$type=$_COOKIE['type'];
$id=$_COOKIE['id'];
if ($type!=null){
	switch ($type) {
		case 0:
			showForStudent($id,$type);
			break;
		case 1:
			showForTeacher($id,$type);
			break;
		case 2:
			showForAdmin($id,$type);
			break;
	}
}
else{
	showForNotLogin();
}
mysql_close($conn);

function showForStudent($id,$type){
	$row = getInfo($id,"student");

	sayHello($type,$row);

	echo "<p><a href=\"info.php\" target=\"mainFrame\">查看个人信息</a></p>";
	echo "<p><a href=\"xuanke.php?id=$row[0]\" target=\"mainFrame\">选课</a></p>";
	echo "<p><a href=\"getcourseinfo.php?id=$row[0]\" target=\"mainFrame\">查看选课信息</a></p>";
	echo "<p><a href=\"modifystu.php?id=$row[0]\" target=\"mainFrame\">修改个人信息</a></p>";
	echo "<p><a href=\"changepass.php\" target=\"mainFrame\">修改密码</a></p>";
}

function showForTeacher($id,$type){
	$row = getInfo($id,"teacher");

	sayHello($type,$row);

	echo "<p><a href=\"info.php\" target=\"mainFrame\">查看个人信息</a></p>";
	echo "<p><a href=\"mystudent.php?id=$row[0]\" target=\"mainFrame\">查看所教学生信息</a></p>";
	echo "<p><a href=\"changepass.php\" target=\"mainFrame\">修改密码</a></p>";
}

function showForAdmin($id,$type){
	$row = getInfo($id,"admin");

	sayHello($type,$row);
	echo "<p>添加信息：</p>";
	echo "<p><a href=\"addcou.htm\" target=\"mainFrame\">添加课程信息</a></p>";
	echo "<p><a href=\"adddept.htm\" target=\"mainFrame\">添加院系信息</a></p>";
	echo "<p><a href=\"addstu.htm\" target=\"mainFrame\">添加学生信息</a></p>";
	echo "<p><a href=\"addtea.htm\" target=\"mainFrame\">添加教师信息</a></p>";
	echo "<p>查询信息：</p>";
	echo "<p><a href=\"searchcou.htm\" target=\"mainFrame\">查询课程信息</a></p>";
	echo "<p><a href=\"searchstu.htm\" target=\"mainFrame\">查询学生信息</a></p>";
	echo "<p><a href=\"searchtea.htm\" target=\"mainFrame\">查询教师信息</a></p>";
	echo "<p><a href=\"whotakecourse.htm\" target=\"mainFrame\">查询选课信息</a></p>";
	echo "<p><a href=\"takenocourse.php\" target=\"mainFrame\">查询未选课学生信息</a></p>";
	echo "<p>删除信息：</p>";
	echo "<p><a href=\"delstu.htm\" target=\"mainFrame\">删除学生信息</a></p>";
	echo "<p><a href=\"deltea.htm\" target=\"mainFrame\">删除教师信息</a></p>";
	echo "<p><a href=\"deldept.htm\" target=\"mainFrame\">删除院系信息</a></p>";
	echo "<p><a href=\"changepass.php\" target=\"mainFrame\">修改密码</a></p>";
}

function showForNotLogin(){
	echo "No Login.";
}

function getInfo($id,$type){
	$sql = "SELECT * FROM $type WHERE `id` = '$id'";
	$result=mysql_query($sql);
	$row = mysql_fetch_row($result);
	return $row;
}

function sayHello($type,$row){
	echo "Welcome, ";
	switch ($type) {
		case 0:
			echo "Student ";
			break;
		case 1:
			echo "Teacher ";
			break;
		case 2:
			echo "Administrator ";
			break;
	}
	echo $row[1];
}
?>
</body>
</html>
